#coding=utf-8

# 1、定义一个func(folder),删除该folder下的所有文件
import os
import os.path
import random

def func(folder):
    for file in os.listdir(folder):
        folderFile = os.path.join(folder, file)
        if os.path.isfile(folderFile):
            os.remove(folderFile)

func("dirt")

def calculateMon(capital,r):
    """
    假设一年期定期利率为3.25%，计算一下需要过多少年，一万元的一年定期存款连本带息能翻番
    :param capital:
    :param r:
    :return: y
    """
    cap = capital
    y = 0
    while True:
        cap = (1+r)*cap
        y = y + 1
        if cap >= 2 * capital:
            break
    return y

print calculateMon(10000,0.0325)

def delodd(num):
    """
    编写程序，生成一个包含50个随机整数的列表，然后删除其中所有奇数
    :param num:
    :return: even_list
    """
    data = []
    even_list = []
    for i in range(num):
        num = random.randint(0, 100)
        data.append(num)

    for i in data:
        if i % 2 == 0:
            even_list.append(i)
    return even_list
print delodd(50)

def animalsNum(num):
    """
    # 一个笼子里面关了鸡和兔子(鸡有 2 只脚,兔子有 4 只脚,没有例外)。已经知道了笼子里面脚的总数a,
    # 问笼子里面至少有多少只动物,至多有多少只动物？
    :param num:
    :return: min_num,max_num
    """
    min_num = 0
    max_num = 0
    rabbit_num = num // 4
    chiken_num = (num-4) // 2

    min_num = rabbit_num + 1
    max_num = chiken_num + 1
    return min_num,max_num

print animalsNum(10)

def rabbit(month):
    """
    兔子繁衍问题
    :param month:
    :return:
    """
    if month <= 2:
        return 2
    else:
        return rabbit(month-1) + rabbit(month-2)

month = int(raw_input('月数：'))
for i in range(0,month):
    print rabbit(i),

def reboundHeight(height,times):
    """
    求反弹高度和距离
    :param height:
    :param times:
    :return: high,distance
    """
    high = height
    distance = height
    for i in range(times):
        high = high/2.0
        distance = distance + high*2
    return high,distance

print reboundHeight(100,10)


def match():
    """
    match the competitor
    :return:i,j,k
    """
    teamlist = ['x','y','z']
    for i in teamlist:
        for j in teamlist:
            for k in teamlist:
                if (i=='x')or(j==i)or(k=='x')or(k=='z')or(k==i)or(k==j):
                    continue
                return i, j, k

print 'a,b,c match'
print match()